
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">


<jsp:useBean id="pizzaManager" scope="request" class="com.ifips5.nal.epizza.web.PizzaManager" />
<c:set var="pizzaList" value="${pizzaManager.pizzaList}" />

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>ePizza - Vente de Pizza en ligne</title>
 	<link rel="stylesheet" type="text/css" href="main.css" media="screen" />
        <link rel="alternate" type="application/rdf+xml" title="RSS 2.0" href="rss/listPizza">
        <link rel="alternate" type="application/rdf+xml" title="RSS 2.0" href="rss/listCommandes">
 
 </head>
    <body>
    
    <!-- Création d'un div page pour gérer les padding ? -->
       <div id="header">
           <img id="logo" src="img/Logo.jpg" alt="ePizza" title="Vente de Pizzas en ligne" />
       </div> 

        <div id="menu">
                  <c:url var="url" value="/Admin" />
            <a href="${url}">Admin</a>
            
            <c:url var="url" value="/Home" />
            <a href="${url}">Home</a>

            <c:url var="url" value="/Admin/Pizzas" />
            <a href="${url}">Pizzas</a>
            
        </div>
        
        
        <div id="content">
            <h2>Liste des pizzas</h2>
            
            <!--
            <ul>
                <c:forEach items="${pizzaList}" var="currentPizza">
                    <li>
                        ${currentPizza.name} (
                        <c:forEach items="${currentPizza.ingredients}" var="currentIngredient" varStatus="statut">
                            <c:choose>
                                <c:when test="${!statut.last}">${currentIngredient.name}, </c:when>
                                <c:otherwise>
                                    ${currentIngredient.name}
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>)
                    </li>
                </c:forEach>
            </ul>
            -->
            
            <!-- chargement des fichiers XML et XLS : -->
            
            <c:url var="urlxml" value="temp/epizza.xml" />            
            <c:import url="${urlxml}" var="stockXml"/>

            <c:url var="urlxsl" value="temp/html.xsl" />            
            <c:import url="${urlxsl}" var="stockXsl"/>
            <!-- Transformation XLS : -->
            
            <x:transform doc="${stockXml}" xslt="${stockXsl}"/>
            
            
            
            <h2>Recherche</h2>
            <c:url var="url" value="/Recherche" />
            <form action="${url}" method="post" >
                <input type="text" name="recherche" id="recherche"/>
                <input type="submit" value="Rechercher"/>
            </form>
            
            <h2>Passer une commande</h2>
            <c:url var="url" value="/Commande" />
            <a href="${url}">Commandez !</a>
            <c:if test="${pb2 == true}">
                <c:set scope="session" var="pb2" value="${false}"/>
                <p style="color: red;">Vous devez être connecté pour commander</p>
            </c:if>
            
            <h2>Nos produits</h2>
            <c:url var="url" value="/temp/ePizzaDB.pdf" />
            <a href="${url}">télécharger</a>
            
            
            <h2>Flux RSS</h2>
            <a href="rss/listPizza">Liste des pizza</a><br />
            <a href="rss/listCommandes">Liste des commandes passées</a>
            
            <div id="login">
                <h2>Connexion</h2>
            <c:choose>
                <c:when test="${empty sessionScope.userId}">
                   
                    <c:url var="url" value="/Login" />
                    <form action="${url}" method="post">
                        <label for="login">Login : </label>        
                        <input type="text" name="login" id="login" /><br />
                        <label for="pwd">Password : </label>        
                        <input type="text" name="pwd" id="pwd" /><br />
                            <c:url var="url" value="/Inscription" />
                            <a href="${url}">S'inscrire...</a><br />
                        <input type="submit" value="Connexion"/>
                    </form>
                    <c:if test="${pb == true}">
                        <p style="color: red;">Mauvais login ou mot de passe</p>
                    </c:if>
                </c:when>
                <c:otherwise>
                    <p>Vous êtes connecté</p>
                    <c:url var="url" value="/Logout" />
                    <form action="${url}" method="post">
                        <input type="submit" value="Déconnexion..."/>
                    </form>
                </c:otherwise>
            </c:choose>             
                
                
            
            </div>

       </div>
       
        <div id="footer"></div>
    </body>
</html>
